package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 东莞呵呵
 * Date:2022-05-19
 * Time:21:11
 */
public class AddOperation implements IOperation{
    @Override
    public void work(BookList booklist) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入书名->");
        String name=scanner.nextLine();
        System.out.println("请输入作者->");
        String author=scanner.nextLine();
        System.out.println("请输入价格->");
        int price= scanner.nextInt();
        scanner.nextLine();//吃掉换行符
        System.out.println("请输入类型->");
        String type=scanner.nextLine();
        Book newBook=new Book(name,author,price,type);
        booklist.setBook(booklist.getSize(),newBook);
        booklist.setSize(booklist.getSize()+1);
        System.out.println("添加成功！");
    }
}
